package main

import "fmt"

type Shaper interface {
	Area() float32
}

type Square struct {
	side float32
}

func (sq *Square) Area() float32 {
	return sq.side * sq.side
}

type Reactangle struct {
	length, width float32
}

func (r Reactangle) Area() float32 {
	return r.length * r.width
}

func main() {
	r := Reactangle{5, 3}
	s := &Square{5}
	shapers := []Shaper{r, s}
	fmt.Println("通过shapers循环计算出面积..")
	for n, _ := range shapers {
		fmt.Println("详情:", shapers[n])
		fmt.Println("这个形状的面积是:", shapers[n].Area())
	}
}
